package dao.factory;

import dao.NewsDao;
import dao.impl.NewsDaoImpl;
import dao.impl.NewsDaoMySqlImpl;
import dao.impl.NewsDaoOracleImpl;
import dao.impl.NewsDaoRedisImpl;

/**
 * @Description
 * @Author 李楚鹏
 * @Date 2024/11/29 10:28
 **/

public class SimpleDaoFactory {
    public static NewsDao getInstance(String key){
        //return new NewsDaoImpl();
        switch (key){
            case "mysql":
                return new NewsDaoMySqlImpl();
            case "oracle":
                return new NewsDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
            default:
                throw new RuntimeException("无效的数据类型："+key+"，DAO获取失败");
        }
    }
}
